<template>
  <div>
    keep-alive 使用，保存上次输入信息
    <keep-alive>
      <bcomp v-if="isshow"></bcomp>
      <acomp v-else></acomp>
    </keep-alive>
    <button @click="toggle">toggle</button>
  </div>
</template>
<script>
import acomp from '../components/keepcomp/a.vue'
import bcomp from '../components/keepcomp/b.vue'
export default {
  components: {
    acomp,
    bcomp
  },
  data () {
    return {
      isshow: false
    }
  },
  methods: {
    toggle () {
      this.isshow = !this.isshow
    }
  }
}
</script>
